Skip to content

cli/api: add --jurisdiction and document the command#1631

Merged
Soph merged 3 commits into
mainfrom
soph/cli-api-jurisdiction
Jul 7, 2026
Merged

cli/api: add --jurisdiction and document the command#1631
Soph merged 3 commits into
mainfrom
soph/cli-api-jurisdiction

Conversation

@Soph

@Soph Soph commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

What

  • Add --jurisdiction <slug> (short -j) to entire api (e.g. us, eu) to target a specific jurisdiction's entire-api cell instead of the caller's home cell.
  • Document entire api in CLAUDE.md, which was missing it entirely.
# home cell (unchanged)
entire api --to cell /api/v1/me/activity

# a specific jurisdiction's cell (implies --to cell)
entire api --jurisdiction eu /api/v1/me/activity
entire api -j eu /api/v1/me/activity

Why

entire api --to cell only ever reached the caller's home entire-api cell. There was no way to call a different jurisdiction's cell from the CLI, even though the underlying cell client (auth.NewEntireAPICellClient + auth.CellTarget) already supports pinning a jurisdiction. This is the sibling of PR #1619, which added --jurisdiction to entire auth token.

Details

  • Reuses existing machinery, no new security logic. --jurisdiction passes auth.CellTarget{Jurisdiction: slug} into NewEntireAPICellClient, which mints the jurisdictional identity token (RFC 8693, scope=openid, aud=<jurisdiction host>) and resolves that jurisdiction's cell URL from the cluster catalog — the same audited path used elsewhere.
  • --jurisdiction implies --to cell. Combining it with an explicit --to core is a contradiction and errors clearly (--jurisdiction targets a cell; use --to cell (not --to core)). The slug is normalized to a bare lowercase DNS label (US/" us "us); NewEntireAPICellClient validates it as a label.
  • -j shorthand. Added alongside the existing -X/-f/-F/-H/-i shorthands (-j was free).
  • Agent discoverability. entire api was already visible in entire help and entire agent-help, and agent-help renders live from the Cobra tree — so the updated Long, Example, and flag usage explain --jurisdiction automatically on entire agent-help api drill-down. No annotation changes needed.

Testing

  • New table-driven TestResolveAPITarget covers pass-through, implied-cell + slug normalization, explicit cell, and the --to core contradiction.
  • mise run fmt + mise run lint clean.
  • go test ./cmd/entire/cli/ ./cmd/entire/cli/auth/ passes.
  • Verified against the built binary: entire api --help / entire agent-help api show the flag (-j, --jurisdiction) + examples, and entire api --to core --jurisdiction eu emits the contradiction error.

🤖 Generated with Claude Code

`entire api --to cell` only reached the caller's home entire-api cell.
Add `--jurisdiction <slug>` (e.g. us, eu) to target a specific
jurisdiction's cell instead, reusing the existing cell machinery: it
passes `auth.CellTarget{Jurisdiction: slug}` into NewEntireAPICellClient,
which mints the jurisdictional identity token and resolves that
jurisdiction's cell URL. No new exchange/URL/security logic.

`--jurisdiction` targets a cell, so it implies `--to cell`; combining it
with an explicit `--to core` is a contradiction and errors clearly. The
slug is normalized to a bare lowercase DNS label (US/" us " -> us).

Surface it to agents: the command was already visible in `entire help`
and `entire agent-help`, and agent-help renders live from the Cobra tree,
so the updated Long/Example/flag-usage explain `--jurisdiction`
automatically on drill-down. Also document `entire api` in CLAUDE.md,
which was missing it entirely.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 2e2d0343f4a1
Copilot AI review requested due to automatic review settings July 4, 2026 16:49
@Soph Soph requested a review from a team as a code owner July 4, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for calling a specific jurisdiction’s entire-api cell from entire api, and documents the command surface so it’s discoverable via help/agent-help and CLAUDE.md.

Changes:

  • Add --jurisdiction <slug> to entire api, with slug normalization and a --to core + --jurisdiction contradiction error.
  • Thread the resolved jurisdiction into cell client construction via auth.CellTarget{Jurisdiction: ...}.
  • Document api in CLAUDE.md alongside the other top-level commands.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/api_cmd.go Adds --jurisdiction, resolves --to/--jurisdiction interplay, and passes jurisdiction into cell client creation.
cmd/entire/cli/api_cmd_test.go Updates client tests for new signature and adds coverage for target resolution behavior.
CLAUDE.md Documents the api command and the new --jurisdiction behavior for users/agents.

Comment thread cmd/entire/cli/api_cmd_test.go Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7e82009. Configure here.

Comment thread cmd/entire/cli/api_cmd.go
Soph and others added 2 commits July 4, 2026 18:53
`-j` is free on the command (used: -X, -f, -F, -H, -i).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 6d4dbe371e4a
Two fixes from PR review:

- Cursor Bugbot (correctness): when `--jurisdiction` was set, the
  CellTarget carried only Jurisdiction (no BaseURL). If the configured
  data origin was already a direct entire-api cell (a ".api." host) rather
  than an apex/BFF, auth kept that origin as the dial target while minting
  an identity token for the *pinned* jurisdiction — so `--jurisdiction eu`
  could mint an EU token but still dial the configured (e.g. US) cell.
  Fix in auth.resolveTargetCellBaseURL: an explicitly pinned jurisdiction
  on a non-loopback origin now resolves that jurisdiction's own cell from
  the cluster catalog (reusing resolveCellAPIBaseURL) instead of dialing
  the origin verbatim. Loopback dev hosts still stay verbatim (single cell,
  no catalog). Only the new Jurisdiction-pinned-without-BaseURL path is
  affected; nil-target (home) and BaseURL-set (repo-scoped experts) paths
  are unchanged.

- Copilot (nit): TestResolveAPITarget now uses the apiTargetCore/
  apiTargetCell constants instead of hard-coded "core"/"cell" literals.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 51810afcea3c
@Soph Soph closed this Jul 7, 2026
@Soph Soph reopened this Jul 7, 2026
@Soph Soph merged commit 739fc24 into main Jul 7, 2026
10 checks passed
@Soph Soph deleted the soph/cli-api-jurisdiction branch July 7, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants